﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Domain.RBAC
{
    /// <summary>
    /// 部门表
    /// 原实体名: Departmentmodel
    /// 修改后实体名: Department (保持类名不变以兼容现有代码)
    /// </summary>
    [SugarTable("departmentmodel", TableDescription = "部门表")]
    public class Departmentmodel : BaseEntity
    {
        /// <summary>
        /// 部门编号（唯一标识）
        /// 原字段名: Departmentcode
        /// 修改后字段名: DepartmentCode
        /// 用途：用于业务层面的部门唯一标识，便于系统集成
        /// </summary>
        [SugarColumn(ColumnDescription = "部门编号", Length = 50, IsNullable = false)]
        public string DepartmentCode { set; get; }

        /// <summary>
        /// 部门名称
        /// 原字段名: Departmentname
        /// 修改后字段名: DepartmentName
        /// </summary>
        [SugarColumn(ColumnDescription = "部门名称", Length = 100, IsNullable = false)]
        public string DepartmentName { set; get; }

        /// <summary>
        /// 父级部门ID（用于构建部门树形结构）
        /// 原字段名: Parentid
        /// 修改后字段名: ParentId
        /// 说明：0表示顶级部门，否则指向父部门的ID
        /// </summary>
        [SugarColumn(ColumnDescription = "父级部门ID", IsNullable = false)]
        public long ParentId { set; get; } = 0;

        /// <summary>
        /// 部门描述/说明
        /// 新增字段
        /// 用途：详细描述部门职责和功能，便于理解部门定位
        /// </summary>
        [SugarColumn(ColumnDescription = "部门描述", Length = 500, IsNullable = true)]
        public string? Description { set; get; }

        /// <summary>
        /// 部门负责人ID
        /// 新增字段
        /// 用途：关联用户表，明确部门管理责任人
        /// </summary>
        [SugarColumn(ColumnDescription = "部门负责人ID", IsNullable = true)]
        public long? LeaderId { set; get; }

        /// <summary>
        /// 部门负责人姓名（冗余字段）
        /// 新增字段
        /// 用途：提高查询性能，避免频繁关联用户表
        /// </summary>
        [SugarColumn(ColumnDescription = "部门负责人姓名", Length = 50, IsNullable = true)]
        public string? LeaderName { set; get; }

        /// <summary>
        /// 排序号（同级部门排序）
        /// 新增字段
        /// 用途：控制部门在列表和树形结构中的显示顺序
        /// </summary>
        [SugarColumn(ColumnDescription = "排序号", IsNullable = false)]
        public int Sort { set; get; } = 0;

        /// <summary>
        /// 部门状态（1-启用，0-禁用）
        /// 新增字段
        /// 用途：支持部门的启用和禁用，禁用后该部门下的用户不能登录
        /// </summary>
        [SugarColumn(ColumnDescription = "部门状态", IsNullable = false)]
        public int Status { set; get; } = 1;

        /// <summary>
        /// 联系电话
        /// 新增字段
        /// 用途：记录部门联系方式，便于沟通协调
        /// </summary>
        [SugarColumn(ColumnDescription = "联系电话", Length = 20, IsNullable = true)]
        public string? Phone { set; get; }

        /// <summary>
        /// 部门邮箱
        /// 新增字段
        /// 用途：记录部门公共邮箱，用于系统通知和邮件发送
        /// </summary>
        [SugarColumn(ColumnDescription = "部门邮箱", Length = 100, IsNullable = true)]
        public string? Email { set; get; }

        /// <summary>
        /// 备注信息
        /// 新增字段
        /// 用途：记录其他需要说明的信息
        /// </summary>
        [SugarColumn(ColumnDescription = "备注", Length = 500, IsNullable = true)]
        public string? Remark { set; get; }
    }
}
